<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>登录 - 五四宪法历史资料陈列馆</title>
    <link rel="stylesheet" href="/static/css/style.css">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/common.js"></script>
</head>
<body>
<div class="main">
    <div class="login">
        <p class="login-header">博物馆预约</p>
        <div class="login-body">
            <p>
                <img src="/static/image/login-t.png" alt="">
                <input type="text" placeholder="请输入手机号码" id="mobile" onblur="checkMobile(this.value)">
            </p>
            <p>
                <img src="/static/image/login-v.png" alt="">
                <input type="password" placeholder="请输入密码" id="pwd">
            </p>
            <a href="javascript:;" class="login-submit" id="doLogin">登录</a>
            <a href="register" class="reg">注册</a>
        </div>
    </div>
</div>
<script>
    function checkMobile(tel) {
        var reg = /(^1[3|4|5|7|8][0-9]{9}$)/;
        //手机号格式正确
        if (reg.test(tel)) {
            return true;
        } else {
            // alert('手机号码有误，请确认。');
            layer.msg('手机号码有误，请确认',{
                icon: 2,
                title:false,
                time:5000

            })
            return false;
        }
    };
    $("#doLogin").click(function(){
        mobile = $("#mobile").val();
        password = $("#pwd").val();
        $.ajax({
            type: "POST",
            dataType: "json",
            url: 'home_login',
            data:{mobile:mobile,password:password},
            success: function (data) {
                if(data.code==1){
                    // alert(data.msg)
                    layer.alert(data.msg,{
                        icon: 3,
                        title:false,
                        // time:5000
                    })
                    location.href='user_index';

                }else {
                    layer.alert(data.msg,{icon:2},3);

                }
            }
        })
    });
</script>
</body>
</html>